9cd56baf00e1354157c2c96b9270bbc2a2e3c1ca,src/org/exist/storage/NativeTextEngine.java,InvertedIndex,remove,#,937
Before Change
for (byte currentSection = 0; currentSection <= ATTRIBUTE_SECTION; currentSection++) {
for (Iterator i = words[currentSection].entrySet().iterator(); i.hasNext();) {
//Compute a key for the token
entry = (Map.Entry) i.next();
storedOccurencesList = (OccurrenceList) entry.getValue();
token = (String) entry.getKey();
ref = new WordRef(collectionId, token);
newOccurencesList = new OccurrenceList();
os.clear();
try {
lock.acquire(Lock.WRITE_LOCK);
value = dbTokens.get(ref);
//Does the token already has data in the index ?
if (value != null) {
//Add its data to the new list
is = new VariableByteArrayInput(value.getData());
try {
while (is.available() > 0) {
storedDocId = is.readInt();
storedSection = is.readByte();
termCount = is.readInt();
size = is.readFixedInt();
if (storedSection != currentSection || storedDocId != this.doc.getDocId()) {
// data are related to another section or document:
// append them to any existing data
os.writeInt(storedDocId);
os.writeByte(storedSection);
os.writeInt(termCount);
os.writeFixedInt(size);
is.copyRaw(os, size);
} else {
// data are related to our section and document:
// feed the new list with the GIDs
previousGID = 0;
for (int j = 0; j < termCount; j++) {
delta = is.readLong();
storedGID = previousGID + delta;
freq = is.readInt();
// add the node to the new list if it is not
// in the list of removed nodes
if (!storedOccurencesList.contains(storedGID)) {
After Change
for (byte currentSection = 0; currentSection <= ATTRIBUTE_SECTION; currentSection++) {
for (Iterator i = words[currentSection].entrySet().iterator(); i.hasNext();) {
//Compute a key for the token
Map.Entry entry = (Map.Entry) i.next();
OccurrenceList storedOccurencesList = (OccurrenceList) entry.getValue();
String token = (String) entry.getKey();
WordRef ref = new WordRef(collectionId, token);
OccurrenceList newOccurencesList = new OccurrenceList();
os.clear();
try {
lock.acquire(Lock.WRITE_LOCK);
Value value = dbTokens.get(ref);
//Does the token already has data in the index ?
if (value != null) {
//Add its data to the new list
VariableByteArrayInput is = new VariableByteArrayInput(value.getData());
try {
while (is.available() > 0) {
int storedDocId = is.readInt();
byte storedSection = is.readByte();
int termCount = is.readInt();
//TOUNDERSTAND -pb
int size = is.readFixedInt();
if (storedSection != currentSection || storedDocId != this.doc.getDocId()) {
// data are related to another section or document:
// append them to any existing data
os.writeInt(storedDocId);
os.writeByte(storedSection);
os.writeInt(termCount);
os.writeFixedInt(size);
is.copyRaw(os, size);
} else {
// data are related to our section and document:
// feed the new list with the GIDs
long previousGID = 0;
for (int j = 0; j < termCount; j++) {
long delta = is.readLong();
long storedGID = previousGID + delta;
int freq = is.readInt();
// add the node to the new list if it is not
// in the list of removed nodes
if (!storedOccurencesList.contains(storedGID)) {